home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / Unmangler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-18  |  3.5 KB  |  86 lines  |  [TEXT/MPS ]

  1. /*---------------------------------------------------------------------------*
  2.  |                                                                           |
  3.  |                            <<< Unmangler.h >>>                            |
  4.  |                                                                           |
  5.  |                         C++ Function Name Decoding                        |
  6.  |                                                                           |
  7.  |              Copyright Apple Computer, Inc. 1988-1991, 1995               |
  8.  |                           All rights reserved.                            |
  9.  |                                                                           |
  10.  *---------------------------------------------------------------------------*/
  11.  
  12. #ifndef __UNMANGLER__
  13. #define __UNMANGLER__
  14.  
  15. #include <stddef.h>
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21. int unmangle(char *dst, char *src, int limit);
  22.     /*
  23.     This function unmangles C++ mangled symbols (i.e. a symbol with a type signature).  The
  24.     mangled C string is passed in src and the unmangled C string is returned in dst.  Up to
  25.     limit characters (not including terminating null) may be returned in dst.
  26.     
  27.     The function returns,
  28.     
  29.          -1 ==> error, probably because symbol was not mangled, but looked like it was
  30.             0 ==> symbol wasn't mangled; not copied either
  31.             1 ==> symbol was mangled; unmangled result fit in buffer
  32.             2 ==> symbol was mangled; unmangled result truncated to fit in buffer (null written)
  33.  
  34.     Caution: the src and dst string must not overlap!
  35.     */
  36.  
  37.  
  38. pascal int Unmangle(char *dst, char *src, int limit);
  39.     /*
  40.     This is identical to unmangle (above) except that this routine is provided for Pascal.
  41.     The src string is assumed to be a Pascal string and the returned string is a Pascal
  42.     string.
  43.     */
  44.     
  45.  
  46. char *unmangle_ident(char *pchIdent);
  47.     /*
  48.     This routine acts as "glue code" or a cover routine to map Symantec's standard unmangler
  49.     calling conventions into Apple's.  This routine accepts a mangled C++ name as a C string
  50.     and returns a pointer to the malloc'ed unmangled name.  NULL is returned if no unmangling
  51.     was done (due to an error or truncation).
  52.     
  53.   Note, it is assumed the buffer malloc'ed here should be freed by the caller.  Also, the
  54.   maximum unmangled string returned is 1023 characters.
  55.     */
  56.  
  57.  
  58. char *unmangle_pt(char **pt);
  59.     /*
  60.     This routine takes a pointer (*pt) to a mangled parameterized type (template) (i.e., the
  61.     mangled strings starts with "__PT") and returns a pointer to the malloc'ed unmangled
  62.     string.  *pt is updated to point to the first character in the string that follows the
  63.     mangled template string (i.e., the one that stoped the parse).
  64.      
  65.     Note, it is assumed the buffer malloc'ed here should be freed by the caller.  Also this
  66.     routine is generally only used for special internal purposes like the Symantec and MrC[pp]
  67.     compilers.  The maximum unmangled string returned is 1023 characters.
  68.     */
  69.  
  70.  
  71. void MWUnmangle(const char *mangled_name, char *unmangled_name, size_t buffersize);
  72.     /*
  73.     This routine acts as "glue code" or a cover routine to map MetroWerks standard unmangler
  74.     calling conventions into Apple's.  This routine accepts a C++ mangled_name as a C string
  75.     and returns the unmangled name in unmangled_name.  If there are any errors, the 
  76.     unmangled_name is simply copied into the mangled_name.  Up to buffersize characters
  77.     (including a delimiting null) are copied to the mangled_name.  Truncation of the mangled
  78.     name is considered an error.
  79.     */
  80.     
  81.  
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif    /* __UNMANGLER__ */
  86.